package com.ymttest.business.service.shenqi;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;

import com.shop2cn.iapi.liveordermanage.parameter.UserClickReq;
import com.shop2cn.iapi.liveordermanage.service.UserClickCall;
import com.ymttest.database.sqlwapper.shenqi.SqliveClickRecordWrapper;
import com.ymttest.utils.TestDataManager;

public class SqUserClickService {

	public static void userClick(Long userId, Long sellerId, String productId)
			throws ClientProtocolException, IOException {

		userClick(userId, sellerId, productId, 2);
	}

	public static void userClick(Long userId, Long sellerId, String productId,
			int liveSource) throws ClientProtocolException, IOException {

		UserClickReq userClickReq = new UserClickReq();
		UserClickCall userClickCall = new UserClickCall();

		userClickReq.setLiveId((long) TestDataManager.getRandomIntNum(10));
//		userClickReq.setLiveId((long) 32);
		userClickReq.setProductId(productId);
		userClickReq.setSellerId(sellerId);
		userClickReq.setUserId(userId);
		userClickReq.setTraceKey("setTraceKey");
		userClickReq.setLiveSource(liveSource);

		userClickCall.setData(userClickReq);
		userClickCall.callService();
	}

	public static void updateUserClickAddTime(Long userId, Long sellerId,
			String productId, String addTime) {

		SqliveClickRecordWrapper sqliveClickRecordWrapper = new SqliveClickRecordWrapper();

		sqliveClickRecordWrapper.updateAddTimeByUserIdAndSellerIdAndProductId(
				userId, sellerId, productId, addTime);
	}
}
